var QQMapWX = require("../../libs/qqmap-wx-jssdk.js");
var qqmapsdk;
Page({
    data: {
        latitude: "", //地图初次加载时的纬度坐标
        longitude: "", //地图初次加载时的经度坐标
        name: "", //选择的位置名称
    },
    onLoad: function() {
        // 实例化API核心类
        qqmapsdk = new QQMapWX({
            key: "MNXBZ-G5TWD-GYF42-HHZJL-2W2J3-PVBX4",
        });
        this.moveToLocation();
    },
    //移动选点
    moveToLocation: function() {
        wx.getLocation({
            type: "gcj02", //返回可以用于wx.openLocation的经纬度
            altitude: false,
            success: (result) => {
                console.log(result);

                wx.chooseLocation({
                    success: function(res) {
                        console.log(res.name);
                        wx.setStorageSync('address', res.name);

                        //选择地点之后返回到原来页面
                        wx.reLaunch({
                            url: "../index/index?address=" + res.name,
                        });
                    },
                });
            },
        });
    },
});